<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<script>
    fetch('http://localhost:8080/users',{
        method:'GET'
    }).then(response=>{
        console.log(response);
        //可以把响应体转成json对象
        return response.json();
    }).then(data=>{
        console.log(data)
    });

    fetch('http://localhost:8080/users',{
        method:'POST',
        body:JSON.stringify({name:'xx'}),
        headers:{'Content-Type':'application/json'}
    }).then(response=>{
        console.log(response);
        //可以把响应体转成json对象
        return response.json();
    }).then(data=>{
        console.log(data)
    });
    fetch('http://localhost:8080/users?id=1',{
        method:'DELETE'
    }).then(response=>{
        console.log(response);
        //可以把响应体转成json对象
        return response.json();
    }).then(data=>{
        console.log(data)
    });
    fetch('http://localhost:8080/users?id=1',{
        method:'PUT',
        body:JSON.stringify({name:'yy'}),
        headers:{'Content-Type':'application/json'}
    }).then(response=>{
        console.log(response);
        //可以把响应体转成json对象
        return response.json();
    }).then(data=>{
        console.log(data)
    });
</script>
</body>
</html>